package com.originskyseed.platform.user.service;

import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.originskyseed.platform.core.base.BasePage;
import com.originskyseed.platform.user.model.Dept;

/**
 * 部门表Service接口类（OSI_DEPT）
 *
 * @author Tangwanghui
 */
public interface IDeptService {

	/**
	 * 删除记录
	 *
	 * @param id
	 * @return
	 * @throws Exception
	 */
	public int deleteByPrimaryKey(String id) throws Exception;

	/**
	 * 批量删除记录
	 *
	 * @param ids
	 * @return
	 * @throws Exception
	 */
	public int deleteByPrimaryKeys(List<String> ids) throws Exception;


	/**
	 * 批量删除记录
	 *
	 * @param ids
	 * @return
	 * @throws Exception
	 */
	public int updateIsDel(List<String> ids) throws Exception;

	/**
	 * 插入记录
	 *
	 * @param record
	 * @return
	 * @throws Exception
	 */
	public int insert(Dept record) throws Exception;

	/**
	 * 插入记录（仅非空值字段）
	 *
	 * @param record
	 * @return
	 * @throws Exception
	 */
	public int insertSelective(Dept record) throws Exception;

	/**
	 * 更新记录
	 *
	 * @param record
	 * @return
	 * @throws Exception
	 */
	public int updateByPrimaryKey(Dept record) throws Exception;

	/**
	 * 更新记录（仅非空值字段）
	 *
	 * @param record
	 * @return
	 * @throws Exception
	 */
	public int updateByPrimaryKeySelective(Dept record) throws Exception;

	/**
	 * 置顶接口
	 *
	 * @param record
	 * @return
	 * @throws Exception
	 */
	public int updateIsTop(Dept record) throws Exception;

	/**
	 * 查询记录
	 *
	 * @param id
	 * @return
	 * @throws Exception
	 */
	public Dept selectByPrimaryKey(String id) throws Exception;

	/**
	 * 查询记录
	 *
	 * @param id
	 * @return
	 * @throws Exception
	 */
	public Dept selectByPrimaryKeyTenantCode(String id,String tenantCode) throws Exception;

	/**
	 * 查询列表
	 *
	 * @param record
	 * @return
	 * @throws Exception
	 */
	public List<Dept> selectList(Dept record) throws Exception;

	/**
	 * 分页查询列表
	 *
	 * @param params
	 * @param page
	 * @return
	 * @throws Exception
	 */
	public BasePage<Dept> selectListByPage(Map<String, Object> params, BasePage<Dept> page) throws Exception;

	/**
	 * 批量更改部门状态
	 *
	 * @param params
	 * @return
	 * @throws Exception
	 */
	public int updateStatusByIds(Map<String, Object> params) throws Exception;

	/**
	 * 查询部门树
	 *
	 * @return
	 * @throws Exception
	 */
	public JSONArray selectDeptTreeList() throws Exception;

	/**
	 * 查询部门树
	 *
	 * @return
	 * @throws Exception
	 */
	public JSONArray selectDeptTreeList(Integer sourceSys) throws Exception;

	/**
	 * 查询部门树
	 *
	 * @return
	 * @throws Exception
	 */
	public void selectUserDeptTreeList(Dept dept, JSONObject jsonObject,Integer type) throws Exception;

	/**
	 * 查询部门编号
	 *
	 * @return
	 * @throws Exception
	 */
	public String selectDeptCode() throws Exception;

	/**
	 * 根据code查询
	 *
	 * @param code
	 * @return
	 * @throws Exception
	 */
	public Dept selectByCode(String code) throws Exception;

	/**
	 * 根据code查询
	 *
	 * @param code
	 * @return
	 * @throws Exception
	 */
	public Dept selectByCodeTenantCode(String code, String tenantCode) throws Exception;

	/**
	 * 查询最大的优先级
	 *
	 * @return
	 * @throws Exception
	 */
	public Integer selectPrority() throws Exception;

	/**
	 * 根据优先级查询部门
	 *
	 * @param map
	 * @return
	 * @throws Exception
	 */
	public Dept selectDeptByProritySort(Map<String, Object> map) throws Exception;

	/**
	 * 根据优先级查询部门
	 *
	 * @param prority
	 * @return
	 * @throws Exception
	 */
	public Dept selectDeptByPrority(Integer prority) throws Exception;

	/**
	 * 更新排序信息
	 *
	 * @param downDept
	 * @param upDept
	 * @return
	 * @throws Exception
	 */
	public int updatePrority(Dept downDept, Dept upDept) throws Exception;

	/**
	 * 根据父级code查询
	 *
	 * @param parentCode
	 * @return
	 * @throws Exception
	 */
	public List<Dept> selectByParentCode(String parentCode) throws Exception;

	/**
	 * 查询是否有子级
	 *
	 * @param code
	 * @return
	 * @throws Exception
	 */
	public boolean selectIsHaveChildren(String id,String code) throws Exception;

	/**
	 * 根据父级code查询
	 *
	 * @param parentCode
	 * @return
	 * @throws Exception
	 */
	public List<Dept> selectByParentCodeTenantCode(String parentCode,String tenantCode) throws Exception;

	/**
	 * 查询是否存在子部门
	 *
	 * @param id
	 * @return
	 * @throws Exception
	 */
	public boolean selectExistSon(String id) throws Exception;

	/**
	 * 分页查询列表
	 *
	 * @param params
	 * @param page
	 * @return
	 * @throws Exception
	 */
	public BasePage<Dept> selectListRelComByPage(Map<String, Object> params, BasePage<Dept> page) throws Exception;

	/**
	 * 查询分公司列表 和体系
	 *
	 * @return
	 * @throws Exception
	 */
	public List<Map<String, Object>> selectComposeList(Map<String, String> map) throws Exception;

	/**
	 * 根据父级code和名称查询查询
	 *
	 * @param params
	 * @param page
	 * @return
	 * @throws Exception
	 */
	public BasePage<Dept> selectByParentCodeAndName(Map<String, Object> params, BasePage<Dept> page) throws Exception;

}
